import { useEffect, useState } from 'react'

export function useWindow () {
  const [isMaximized, setIsMaximized] = useState<boolean>(false)

  async function update () {
    setIsMaximized(await window.api.isMaximized())
  }
  useEffect(() => {
    update()
  }, [])

  function maximize () {
    window.api.setWin('max')
    update()
  }
  function minimize () {
    window.api.setWin('min')
  }
  function close () {
    window.api.setWin('close')
  }

  return {
    isMaximized,
    maximize,
    minimize,
    close,
  }
}
